package com.ict.ms.start;

import java.nio.charset.Charset;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.http.converter.HttpMessageConverter;

import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.serializer.ValueFilter;
import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;

/**
 * @ClassName: BusinessRestApplication
 * @Description: 启动类
 * @author TLC
 * @date 2018年04月27日
 */
@SpringBootApplication
@ComponentScan(basePackages = {"com.ict"})
public class BusinessRestApplication {

	/**
	 * @Title: fastJsonHttpMessageConverters @Description: 注入ali
	 * fastJoson进行java对象与网络json相互转换 @return HttpMessageConverters 返回类型 @throws
	 */
	/*@Bean
	public FastJsonHttpMessageConverter fastJsonHttpMessageConverter() {
		FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();

		FastJsonConfig fastJsonConfig = new FastJsonConfig();
		fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat, SerializerFeature.WriteClassName, // 输出类名字
				SerializerFeature.WriteMapNullValue);
		ValueFilter valueFilter = new ValueFilter() {
			// o 是class
			// s 是key值
			// o1 是value值
			public Object process(Object o, String s, Object o1) {
				if (null == o1) {
					o1 = "";
				}
				return o1;
			}
		};
		fastJsonConfig.setSerializeFilters(valueFilter);
		// 可以设置编码，默认UTF-8
		fastJsonConfig.setCharset(Charset.forName("UTF-8"));
		converter.setFastJsonConfig(fastJsonConfig);
		return converter;
	}*/
	public static void main(String[] args) {
		SpringApplication.run(BusinessRestApplication.class, args);
	}
}
